import React, { Component } from 'react'
import UserModel from '../interface/userinterface'
interface IState {
    username: string,
    userpwd: string
}
interface IProps {
    addUserItem: (item: UserModel) => void
}
export default class AddUser extends Component<IProps, IState> {
    constructor(props: any) {
        super(props);
        this.state = {
            username: "",
            userpwd: ""
        }
    }
  render() {
    return (
        <div>
            <div>用户名  <input value={this.state.username} onChange={(e) => {
                this.setState({
                    username: e.target.value
                })

            }} /> </div>
            <div>密码  <input value={this.state.userpwd} onChange={(e) => {
                this.setState({
                    userpwd: e.target.value
                })

            }} /> </div>
            <button onClick={() => {
                this.props.addUserItem({
                    username: this.state.username,
                    userpwd: this.state.userpwd
                })
            }}>新增</button>
        </div>
    )
  }
}
